package com.xczl.demo.test;

import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.xczl.demo.dao.UserLevelDao;
import com.xczl.demo.domain.UserLevel;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({ "classpath:root-context.xml" })
public class UserLevelTestCase {

	@Autowired
	private UserLevelDao userLevelDao;
	
	/**
	 * 添加
	 */
	@Test
	public void insert() {
		UserLevel userLevel = new UserLevel();
		userLevel.setName("钻石会员");
		userLevel.setLevel(5);
		userLevelDao.insertUserLevel(userLevel);
	}
	
	/**
	 * 刪除
	 */
	@Test
	public void deleteById() {
		userLevelDao.deleteById(12);
	}
	
	/**
	 * 修改
	 */
	@Test
	public void updateById() {
		UserLevel userLevel = new UserLevel();
		userLevel.setName("铂金会员");
		userLevel.setUserLevelId(11);
		userLevelDao.updateById(userLevel);
	}
	
	/**
	 * 按主键查询
	 */
	@Test
	public void findById(){
		UserLevel userLevel = userLevelDao.findById(1);
		System.out.println(userLevel.getName());
	}
	
	
	/**
	 * 查询全部
	 */
	@Test
	public void findAll(){
		List<UserLevel> userLevelList = userLevelDao.findAll();
		for(UserLevel temp:userLevelList){
			System.out.println(temp.getName());
		}
	}
	
}
